﻿var commonUI = (function () {

    function init() {

        $('.InvertedActionButton, ActionButton').on('click', function () {
            var $this = $(this);

            var redirectionUrl = $this.attr('data-ref');
            if (redirectionUrl != undefined) {
                document.location = redirectionUrl;
            }

            var isAutoSubmit = $this.attr('data-autosubmit') == 'true';
            if (isAutoSubmit) {
                $this.closest('form').submit();
            }
        });

        $(document).on('click', '.adoptTemplate', function () {
            var $this = $(this);
            var detailPage = $('#petDetailURL').val() + "?itemId=" + $this.attr('data-petid');
            location = detailPage;
        });

    }

    return {
        init: init
    };

})()